﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace ProjManagSolution.Web
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "myWebService" in code, svc and config file together.
    public class myWebService : ImyWebService
    {
        public void DoWork()
        {
        }

        public List<user> GetUsers()
        {
            Models db = new Models();
            return db.getUsers();
        }

        public user GetUserDetails(int userID)
        {
            Models db = new Models();
            return db.getUserDetail(userID);
        }

        public List<project> GetProjects()
        {
            Models db = new Models();
            return db.getProjects();
        }

        public List<project> GetProjectsByManager(int managerID)
        {
            Models db = new Models();
            return db.getProjectsByManager(managerID);
        }

        public List<milestone> GetMilestones(int projectID)
        {
            Models db = new Models();
            return db.getMileStones(projectID);
        }

        public void InsertUser(user newUser)
        {
            Models db = new Models();
            db.insertUser(newUser);
        }

        public List<phase> GetPhases(int milestoneID)
        {
            Models db = new Models();
            return db.getPhases(milestoneID);
        }

        public List<task> GetTasks(int phaseID)
        {
            Models db = new Models();
            return db.getTasks(phaseID);
        }

        public bool GetUserDetailByAuth(string email, string pass)
        {
            Models db = new Models();
            user result = db.getUserDetailByAuth(email ,pass) ;
            
            if (result.user_email == null)
                return false;
            else
                return true;
        }

        public List<project> GetInvolvedProjects(int userID)
        {
            Models db = new Models();
            return db.getInvolvedProjects(userID);
        }

        public void UpdateUserDetails(int userID, user updatedUser)
        {
            Models db = new Models();
            db.updateUserDetail(userID, updatedUser);
        }

        public void InsertProject(project newProject)
        {
            Models db = new Models();
            db.insertProject(newProject);
        }

        public project GetProjectDetail(int projectID)
        {
            Models db = new Models();
            return db.getProjectDetail(projectID);
        }

        public void UpdateProjectDetails(int projectID, project updatedProject)
        {
            Models db = new Models();
            db.updateProjectDetail(projectID, updatedProject);
        }

        public void DeleteProject(int projectID)
        {
            Models db = new Models();
            db.deleteProject(projectID);
        }

        public List<user> GetProjectMembers(int projectID)
        {
            Models db = new Models();
            return db.getProjectMembers(projectID);
        }
    }
}
